﻿<%@ Control Language="C#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="Buffalo.Lib.Common" %>
<%@ Import Namespace="Buffalo.SMECommon.DAL.Models" %>
<%@ Import Namespace="Buffalo.SMECommon.DAL" %>
<%@ Import Namespace="Buffalo.Web.Areas.SMECommon" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            string IDCustomer = Util.ToSafeString(ViewData["IDCustomer"]);
            Partner customer = new PartnerDAL().GetPartner(IDCustomer);
            if (!IDCustomer.Equals("0") && !string.IsNullOrEmpty(IDCustomer))
            {
                //cboPartnerType.SelectedIndex = (int)customer.PartnerType - 1;
                cboPartnerType.SetValue(customer.PartnerType);
                cboPartnerCategoryName.SetValue(customer.IDPartnerCategory);
            }
        }
    }
</script>
<ext:FormPanel ID="CustomerInfoForm" runat="server" Border="false" Url="/Partner/SaveCustomerInfo/"
    LabelWidth="135">
    <Items>
        <ext:Container ID="CustomerInfoFormContainer" runat="server" Flex="1" Layout="Column"
            Height="600">
            <Items>
                <ext:Container ID="Container1" runat="server" Layout="Form" ColumnWidth=".5">
                    <Items>
                        <ext:TextField ID="Code" runat="server" FieldLabel="Code" Width="300" />
                        <ext:TextField ID="Name" runat="server" FieldLabel="Name" Width="300" />
                        <ext:Hidden ID="PartnerType" runat="server" />
                        <ext:SelectBox ID="cboPartnerType" runat="server" FieldLabel="PartnerType" Width="300">
                            <Items>
                                <ext:ListItem Text="Customer" Value="1" />
                                <ext:ListItem Text="Supplier" Value="2" />
                                <ext:ListItem Text="CustomerAndSupplier" Value="3" />
                            </Items>
                            <Listeners>
                                <Select Handler="#{PartnerType}.setValue(#{cboPartnerType}.getValue());" />
                            </Listeners>
                        </ext:SelectBox>
                        <ext:Hidden ID="IDPartnerCategory" runat="server" />
                        <ext:ComboBox ID="cboPartnerCategoryName" runat="server" StoreID="dsPartnerCategory" Editable="false"
                            FieldLabel="PartnerCategory" DisplayField="Name" ValueField="ID" TypeAhead="true" Mode="Local"
                            ForceSelection="true" Width="300" TriggerAction="All" SelectOnFocus="true">
                            <Listeners>
                                <Select Handler="#{IDPartnerCategory}.setValue(#{cboPartnerCategoryName}.getValue());" />
                            </Listeners>
                        </ext:ComboBox>

                    </Items>
                </ext:Container>
                <ext:Container ID="Container2" runat="server" Layout="Form" ColumnWidth=".5">
                    <Items>
                    </Items>
                </ext:Container>
            </Items>
        </ext:Container>
    </Items>
    <BaseParams>
        <ext:Parameter Name="IDCustomer" Value='<%# ViewData["IDCustomer"] %>' Mode="Value" AutoDataBind="true" />
    </BaseParams>
</ext:FormPanel>
